<!--#include virtual="/Common/Config.asp" -->
<!--#include virtual="/Common/conn.asp" -->
<!--#include virtual="/2010admin/Check_IsLogin.asp" -->
<!--#include virtual="/Common/Function.asp" -->
<%
Default_Url =Request.ServerVariables("SCRIPT_NAME")
If Request.ServerVariables ("Request_Method")="POST" Then

	'禁止从网站外部提交数据
	Call Deny_OutSiteSubit()

	action = requery("action")

	Select Case action
			Case "add"  Call Add()	
			Case "edit" Call Edit()	
			Case "del"  Call Del()
	End Select
End If

Function Add()

	System_Name = reform("System_Name")

	Order_Pre = reform("Order_Pre")
	
	Call Check_Length(System_Name,20,1,"订单类型")
	Call Check_Length(Order_Pre,10,0,"订单前缀")


	Sql = "INSERT INTO Order_Info(System_Name,Order_Pre) VALUES("&_
		  "'"& System_Name &"'"&_
		  ",'"& Order_Pre &"'"&_
		  ")"


		conn.execute(sql)

	
	AlertBox "增加成功!",Default_Url

End Function 

Function Edit()

	Op_ID_Str = reform("Op_ID")
	If Op_ID_Str="" Then
		AlertBox "请选择要修改的记录!","javascript:history.go(-1)"	
	End If
	
	Op_ID_Array = Split(Op_ID_Str,",")
	
	For i=0 To UBound(Op_ID_Array)
	
		Op_ID   = Trim(Op_ID_Array(i))
		System_Name  = reform("System_Name"&Op_ID)
		Order_Pre = reform("Order_Pre"&Op_ID)
		
		Call Check_Length(System_Name,20,1,"订单类型")
		Call Check_Length(Order_Pre,10,0,"订单前缀")

	Next

	For i=0 To UBound(Op_ID_Array)

		Op_ID    = Trim(Op_ID_Array(i))
		System_Name = reform("System_Name"&Op_ID)
		Order_Pre= reform("Order_Pre"&Op_ID)

		Sql = "UPDATE Order_Info SET System_Name='"& System_Name &"'"&_
			  ",Order_Pre='"& Order_Pre &"'"&_
			  "WHERE OI_ID="& Op_ID

		conn.execute(sql)


	Next
	
	AlertBox "修改成功!",Default_Url
End Function 

Function Del()

	Op_ID = reform("Op_ID")

	'Call Check_IsNumeric(iOI_ID)
	Sql = "DELETE FROM Order_Info WHERE OI_ID IN ("& Op_ID &")"
	conn.execute(sql)

	AlertBox "删除成功!",Default_Url

End Function 


%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="/2010admin/css/default.css" type="text/css" rel="stylesheet">
<title><%=web_title%></title>
<script language="javascript" src="/js/main.js"></script>
<script language="javascript" src="/js/selects.js"></script>
<script language="javascript" src="/js/manage.js"></script>
<script language="javascript" src="/2010admin/js/validator.js"></script>

<script language="javascript"> 
function checkall(field)
{
  var sall = document.form.list2.checked;
  if (field.length)
  {
	slength = field.length;
	for (var i = 0; i < slength; i++) { field[i].checked = sall; }
  }
  else { field.checked = sall; }
}
function checkform()
{
 var groups = document.getElementsByName("Op_ID");
 var hasChecked = 0;
 for(var i=0; i<groups.length;i++)
	if(groups[i].checked) hasChecked++;
	
if(hasChecked==0)
{
	alert("至少选择一条要修改的记录!");
	return false;
}
else document.form.submit();
}
</script> 
<script language="javascript">
<!--
	function delcheck(){
	 var groups = document.getElementsByName("Op_ID");
	 var hasChecked = 0;
	 for(var i=0; i<groups.length;i++)
		if(groups[i].checked) hasChecked++;
		
	if(hasChecked==0)
	{
		alert("至少选择一条要删除的记录!");
		return false;
	}

	if (confirm('是否真的要删除这条记录？')) {
		document.form.action="<%=Default_Url%>?action=del";
		document.form.submit();
	}
	else return false;
}
//-->
</script>
</head>
<body >
<table border="0" width="100%" cellSpacing="0" cellPadding="0">
  <tr>
    <td width="100%" height="5"></td>
  </tr>
  <tr>
    <td width="100%" align="center">
      <table border="0" width="98%" cellSpacing="0" cellPadding="0">
        <tr>
          <td width="*" align="center" valign="top">
            <table border="0" width="100%" cellSpacing="0" cellPadding="0" class="lrbtline">
              <tr>
                <td width="100%" height="25" class="tbtop">管理导航</td>
              </tr>
              <tr>
                <td width="100%" align="center">
                  <table border="0" width="98%" cellSpacing="0" cellPadding="0">
                    <tr>
                      <td width="100%" height="5"></td>
                    </tr>
                  </table>
                  <table border="0" width="98%" cellSpacing="0" cellPadding="0">
                    <tr>
                      <td width="100%" height="20">&nbsp;<img src="/2010admin/images/sico.gif" border="0">&nbsp;<span id="userlist"><a href="<%=Default_Url%>">订单类型</a></span>&nbsp;&nbsp;<span id="useradd"></span></td>
                    </tr>
                    <tr>
                      <td width="100%" height="5"></td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
            <table border="0" width="100%" cellSpacing="0" cellPadding="0">
              <tr>
                <td width="100%" height="5"></td>
              </tr>
            </table>
			<%
			sql="SELECT OI_ID,System_Name,Order_Pre FROM Order_Info ORDER BY Order_Pre ASC"
			Set rs=conn.execute(sql)

			If Not rs.Eof Then

			%>
            <table border="0" width="100%" cellSpacing="0" cellPadding="0" class="lrbtline">
              <tr>
                <td width="100%" height="25" class="tbtop">修改订单类型</td>
              </tr>
              <tr>
                <td width="100%" align="center">
                  <table border="0" width="98%" cellSpacing="0" cellPadding="0">
                    <tr>
                      <td width="100%" height="5"></td>
                    </tr>
                  </table>
                  <table border="0" width="98%" cellSpacing="0" cellPadding="0">
                  <form action="?action=edit" method="post" name="form" >

                    <tr>
                      <td width="125" height="25"><div align="center">选择</div></td>
                      <td>订单类型</td>
                    <td>订单前缀</td>
                    </tr>
					<%
					Do While Not rs.Eof
						Op_ID	  = rs(0)  						 
						System_Name  = rs(1)
						Order_Pre = rs(2)
						
					%>
                    <tr>
                      <td width="125" height="25"><div align="center">
                        <input name="Op_ID" type="checkbox" id="Op_ID" value="<%=Op_ID%>" >
                      </div></td>
                      <td width="267">
					  <input name="System_Name<%=Op_ID%>" type="text" id="System_Name" value="<%=System_Name%>" size="20" ></td>
                    <td width="974"><input name="Order_Pre<%=Op_ID%>" type="text" id="Order_Pre<%=Op_ID%>" value="<%=Order_Pre%>" size="20" ></td>
                    </tr>
					<%
					rs.movenext
					Loop
					%>
                    <tr>
                      <td width="125" height="25"><div align="center"><input type=checkbox name="list2" onClick="checkall(this.form.Op_ID);"  >

                        </div></td>
                      <td><input type="button" name="button1" value="修改" class="button" onClick="return checkform();">&nbsp;<input type="button" name="button2" value="删除" class="button" onClick="return delcheck();"></td>
                    <td colspan="2">&nbsp;</td>
                    </tr>
                  </form>
                  </table>
                  <table border="0" width="98%" cellSpacing="0" cellPadding="0">
                    <tr>
                      <td width="100%" height="5"></td>
                    </tr>
                  </table>
			 <%
			 End If 

			 rs.close
			 %>

            <table border="0" width="100%" cellSpacing="0" cellPadding="0" class="lrbtline">
              <tr>
                <td width="100%" height="25" class="tbtop">增加订单类型</td>
              </tr>
              <tr>
                <td width="100%" align="center">
                  <table border="0" width="98%" cellSpacing="0" cellPadding="0">
                    <tr>
                      <td width="100%" height="5"></td>
                    </tr>
                  </table>
                  <table border="0" width="98%" cellSpacing="0" cellPadding="0">
                  <form action="?action=add" method="post" name="form1" onSubmit="return Validator.Validate(this, 2)">

                    <tr>
                      <td width="125" height="25">订单类型</td>
                      <td width="1240"><input name="System_Name" type="text" id="System_Name" value="" size="20" dtype="Limit" min="2" max="20" dmsg="订单类型必须在2-20个字符间" ></td>
                    </tr>
                    <tr>
                      <td width="125" height="25">订单前缀</td>
                      <td width="1240"><input name="Order_Pre" type="text" id="Order_Pre" value="" size="20" dtype="Limit" min="0" max="20" dmsg="订单前缀必须在2-20个字符间"></td>
                    </tr>
					
                    <tr>
                      <td height="25" colspan="2"><div align="center">
                        </div>                        <input type="submit" name="submit1" value="修改" class="button"></td>
                      </tr>
                  </form>
                  </table>

                </td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </td>
  </tr>
  <tr>
    <td width="100%" height="5"></td>
  </tr>
</table>
</body>
</html>
<%
Call conn_close()
%>

